/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-01-07
 * Time: 15:10
 */
public class test3 {
    /*
    LeetCode 最后一个单词的长度
     */
    public int lengthOfLastWord(String s) {
        int i = s.length()-1;
        while(s.charAt(i)==' '){
            i--;
        }
        int count=0;
        while(i>=0 && s.charAt(i)!=' '){
            count++;
            i--;
        }
        return count;
    }
}
